﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Attendance
{
    public partial class frmLogin : Form
    {
        private HttpServer httpServer = new HttpServer();
        frmMain main = new frmMain();
        
        public frmLogin()
        {
            InitializeComponent();
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                httpServer.chkLogin(txtAccount.Text, txtPassword.Text, main.Teacher, main.Subject);
                main.Show();
                this.Hide();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                this.txtAccount.Text = "";
                this.txtPassword.Text = "";
            }
        }

        private void test()
        {
            try
            {
                httpServer.chkLogin("test", "test123456", main.Teacher, main.Subject);
                main.Show();
                this.Hide();
            }
            catch (Exception ex)
            {

            } 
        }

        private void frmLogin_Load(object sender, EventArgs e)
        {
            main.Teacher = new DataSet();
            main.Subject = new DataSet();
            //test();
        }
    }
}
